import BuffUtil from '@/BuffUtil';
import UnitSpellEvent from '@/event/UnitSpellEvent';
import BuffCommon from 'code/Core/Common/BuffCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/* 冰冷躯体 */
export default class DK_IceBody extends AbilityBase {
    static instance: DK_IceBody;
    buffType: AppBuffType = {
        id: 'buff_DK_IceBody',
        art: this.art,
        name: this.abilityName,
        ubertip: '受到寒冰的保护，受到的伤害降低',
        dur: 20,
        targetAttach: 'chest',
        targetArt: 'Abilities\\Spells\\Undead\\FrostArmor\\FrostArmorTarget.mdl',
        attribute: {},
    };
    constructor(id: string) {
        super(id);
        DK_IceBody.instance = this;
        this.init();
        se.onUnitSpellEffect(this.spellEffect, this.id);
    }
    spellEffect(d: UnitSpellEvent) {
        let _this = DK_IceBody.instance;
        let u = GetTriggerUnit();
        _this.cast(0, 0, u, u);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        let _this = DK_IceBody.instance;
        let lv = this.getAbilityLevel(source);
        BuffCommon.addBuff({
            target: source,
            caster: source,
            ablityId: _this.id,
            buffTypeId: _this.buffType.id,
            attribute: {
                物理伤害减免: 0.2 + 0.05 * lv,
                法术伤害减免: 0.2 + 0.05 * lv,
            },
        });
    }
}
